
In this part we will discuss the JavaScript data type. When we decliner the variable then we assign the value, this value is must and should some data type. JavaScript have six primitive data type like string, integer, Boolean, null, undefined etc. when we declare the variable to contain the value then we use the “var” keyword. Now given bellow the code and explain the code:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
//int data type
var myInt=10;
console.log(myInt);
//string data type
var myStr1="Farhan Sakib";
console.log(myStr1);
var myStr2='Reza Karim';
console.log(myStr2);
//bool data type
var a=true;
var b=false;
console.log(a);
console.log(b);
//object data type
var person = {
firstName : "Reza",
lastName : "Karim",
age : 29,
eyeColor : "black"
};
console.log(person.firstName + " is " + person.age + " years old.");
</script>
</body>
</html>
In this code we will show the int data type bool data type string data type also object data type. Object contain at a time many properties. This property will be int, string or others data type. We can see person is an object and this person contain the string and int data type at a time.